/*
@Copyright:LintCode
@Author:   tjyemail
@Problem:  http://www.lintcode.com/problem/string-to-integer-ii
@Language: C++
@Datetime: 16-02-09 09:02
*/

class Solution {
public:
    /**
     * @param str: A string
     * @return An integer
     */
    int atoi(string str) {
        // write your code here
        double num=0;
        sscanf(str.c_str(),"%lf",&num);
        if (num >=INT_MAX) return INT_MAX;
        else if (num<=INT_MIN) return INT_MIN;
        else return num;
    }
};